<template>
    <el-table
            :data="tableData"
            stripe

            style="width: 100%;"
            :default-sort = "{prop: 'date', order: 'descending'}"
    >
        <el-table-column
                prop="cameraid"
                label="相机ID"
                sortable
                width="180">
        </el-table-column>
        <el-table-column
                prop="prince"
                label="省份"
                sortable
                width="180">
        </el-table-column>
        <el-table-column
                prop="city"
                label="城市"
                                                                                                                                                                                                                     >
        </el-table-column>
        <el-table-column
                prop="position"
                label="站点"
                width="180">
        </el-table-column>
        <el-table-column
                prop="status"
                label="状态"
                width="180">
        </el-table-column>
        <el-table-column
                fixed="right"
                label="操作"
                width="100">
            <template slot-scope="scope">
                <el-button @click="handleClick(scope.row)"  size="small">查看</el-button>
            </template>
        </el-table-column>
    </el-table>

</template>

<script>
    import API from "../../api";

    export default {
        name: "camera_list",
        data(){
            return{
                tableData: [{
                    cameraid: '1',
                    prince: '北京',
                    status:'fine',
                    city:'北京',
                    state: '北京西站'
                }],
                currentRow: null

            }
        },
        methods:{
            getList(){
                API.cameraList().then(res=>{
                    if(res.code){
                        alert(res.message);
                        return;
                    }
                    this.tableData = res
                }).catch(msg => {
                    if(res.code){
                        alert(res.message);
                        return;
                    }
                    alert(msg)
                })
            },
            handleClick(item){
                console.log(item)
                this.$router.push({path: `/camera/`+item.cameraid+`/main`})
            },


        },
        mounted() {
            this.getList()
        },
    }
</script>

<style scoped>


</style>
